﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Data.SqlTypes;

namespace DataAccess.Operate
{
    public class DA_Report_SalesLink_Operate:SqlInteractionBase
    {
        private DataEntity.T_Report_SalesLink _objMessage = null;
        public override bool Insert(object obj)
        {
            SqlCommand cmdToExecute = new SqlCommand();
            cmdToExecute.CommandText = "dbo.[sp_t_Report_SalesLink_Insert]";
            cmdToExecute.CommandType = CommandType.StoredProcedure;

            // Use base class' connection object
            cmdToExecute.Connection = _mainConnection;
            this._objMessage = (DataEntity.T_Report_SalesLink)obj;
            try
            {
                cmdToExecute.Parameters.Add(new SqlParameter("@guidReport_SalesLink_ID", SqlDbType.UniqueIdentifier, 16, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ID));
                cmdToExecute.Parameters.Add(new SqlParameter("@guidReport_SalesLink_ProjectID", SqlDbType.UniqueIdentifier, 16, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ProjectID));
                cmdToExecute.Parameters.Add(new SqlParameter("@iReport_SalesLink_ExchangeTypeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ExchangeTypeID));
                cmdToExecute.Parameters.Add(new SqlParameter("@iReport_SalesLink_PropertyTypeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_PropertyTypeID));
                cmdToExecute.Parameters.Add(new SqlParameter("@daReport_SalesLink_ExchangeDate", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ExchangeDate));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_ReportNO", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ReportNO));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Subscribe", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Subscribe));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Operator", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Operator));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_SellUnit", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_SellUnit));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Buyer", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Buyer));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_Area", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Area));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Discount", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Discount));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_PayType", SqlDbType.NChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_PayType));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_Price", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Price));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_Margins", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Margins));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_AgencyCost", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_AgencyCost));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_CancelComm", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_CancelComm));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_OriginalArea", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_OriginalArea));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_OriginalPrice", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_OriginalPrice));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_BarchSalse", SqlDbType.NVarChar, 500, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_BarchSalse));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Variations", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Variations));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_IDNumber", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_IDNumber));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Tel", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Tel));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_CustomerAddress", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_CustomerAddress));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_PostCode", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_PostCode));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_SalesArea", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_SalesArea));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_OriginalContractPrice", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_OriginalContractPrice));
                cmdToExecute.Parameters.Add(new SqlParameter("@daReport_SalesLink_BigDate", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_BigDate));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_BigPrice", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_BigPrice));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_BigSumPrice", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_BigSumPrice));
                cmdToExecute.Parameters.Add(new SqlParameter("@daReport_SalesLink_ContractDate", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ContractDate));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_ContractArea", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ContractArea));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_ContractPrice", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ContractPrice));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_ContractSumPrice", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ContractSumPrice));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_LoanAmount", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_LoanAmount));
                cmdToExecute.Parameters.Add(new SqlParameter("@daReport_SalesLink_ContractLoansDate", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ContractLoansDate));
                cmdToExecute.Parameters.Add(new SqlParameter("@daReport_SalesLink_LentDate", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_LentDate));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SSalesLink_LentAmount", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SSalesLink_LentAmount));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_TotalReceipt", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_TotalReceipt));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_RestHouse", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_RestHouse));
                cmdToExecute.Parameters.Add(new SqlParameter("@daReport_SalesLink_GiveHouseDate", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_GiveHouseDate));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Departments", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Departments));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Branches", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Branches));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_SalesNames", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_SalesNames));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_SalesNumber", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_SalesNumber));
                cmdToExecute.Parameters.Add(new SqlParameter("@iReport_Plan_Audit", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Report_Plan_Audit));

                if (_mainConnectionIsCreatedLocal)
                {
                    // Open connection.
                    _mainConnection.Open();
                }
                else
                {
                    if (_mainConnectionProvider.IsTransactionPending)
                    {
                        cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
                    }
                }

                // Execute query.
                _rowsAffected = cmdToExecute.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                // some error occured. Bubble it to caller and encapsulate Exception object
                throw new Exception("T_Report_SalesLink::Insert::Error occured.", ex);
            }
            finally
            {
                if (_mainConnectionIsCreatedLocal)
                {
                    // Close connection.
                    _mainConnection.Close();
                }
                cmdToExecute.Dispose();
            }
        }


        public override bool Update(object obj)
        {
            SqlCommand cmdToExecute = new SqlCommand();
            cmdToExecute.CommandText = "dbo.[sp_t_Report_SalesLink_Update]";
            cmdToExecute.CommandType = CommandType.StoredProcedure;

            // Use base class' connection object
            cmdToExecute.Connection = _mainConnection;
            this._objMessage = (DataEntity.T_Report_SalesLink)obj;
            try
            {
                cmdToExecute.Parameters.Add(new SqlParameter("@guidReport_SalesLink_ID", SqlDbType.UniqueIdentifier, 16, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ID));
                cmdToExecute.Parameters.Add(new SqlParameter("@iReport_SalesLink_ExchangeTypeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ExchangeTypeID));
                cmdToExecute.Parameters.Add(new SqlParameter("@iReport_SalesLink_PropertyTypeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_PropertyTypeID));
                cmdToExecute.Parameters.Add(new SqlParameter("@daReport_SalesLink_ExchangeDate", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ExchangeDate));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_ReportNO", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ReportNO));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Subscribe", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Subscribe));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Operator", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Operator));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_SellUnit", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_SellUnit));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Buyer", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Buyer));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_Area", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Area));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Discount", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Discount));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_PayType", SqlDbType.NChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_PayType));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_Price", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Price));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_Margins", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Margins));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_AgencyCost", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_AgencyCost));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_CancelComm", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_CancelComm));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_OriginalArea", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_OriginalArea));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_OriginalPrice", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_OriginalPrice));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_BarchSalse", SqlDbType.NVarChar, 500, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_BarchSalse));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Variations", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Variations));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_IDNumber", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_IDNumber));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Tel", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Tel));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_CustomerAddress", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_CustomerAddress));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_PostCode", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_PostCode));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_SalesArea", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_SalesArea));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_OriginalContractPrice", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_OriginalContractPrice));
                cmdToExecute.Parameters.Add(new SqlParameter("@daReport_SalesLink_BigDate", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_BigDate));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_BigPrice", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_BigPrice));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_BigSumPrice", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_BigSumPrice));
                cmdToExecute.Parameters.Add(new SqlParameter("@daReport_SalesLink_ContractDate", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ContractDate));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_ContractArea", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ContractArea));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_ContractPrice", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ContractPrice));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_ContractSumPrice", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ContractSumPrice));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_LoanAmount", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_LoanAmount));
                cmdToExecute.Parameters.Add(new SqlParameter("@daReport_SalesLink_ContractLoansDate", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_ContractLoansDate));
                cmdToExecute.Parameters.Add(new SqlParameter("@daReport_SalesLink_LentDate", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_LentDate));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SSalesLink_LentAmount", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SSalesLink_LentAmount));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_TotalReceipt", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_TotalReceipt));
                cmdToExecute.Parameters.Add(new SqlParameter("@dcReport_SalesLink_RestHouse", SqlDbType.Decimal, 9, ParameterDirection.Input, false, 18, 1, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_RestHouse));
                cmdToExecute.Parameters.Add(new SqlParameter("@daReport_SalesLink_GiveHouseDate", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_GiveHouseDate));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Departments", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Departments));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_Branches", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_Branches));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_SalesNames", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_SalesNames));
                cmdToExecute.Parameters.Add(new SqlParameter("@sReport_SalesLink_SalesNumber", SqlDbType.NVarChar, 200, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, this._objMessage.Report_SalesLink_SalesNumber));
                cmdToExecute.Parameters.Add(new SqlParameter("@iReport_Plan_Audit", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, this._objMessage.Report_Plan_Audit));
                if (_mainConnectionIsCreatedLocal)
                {
                    // Open connection.
                    _mainConnection.Open();
                }
                else
                {
                    if (_mainConnectionProvider.IsTransactionPending)
                    {
                        cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
                    }
                }

                // Execute query.
                _rowsAffected = cmdToExecute.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                // some error occured. Bubble it to caller and encapsulate Exception object
                throw new Exception("T_Report_SalesLink::Update::Error occured.", ex);
            }
            finally
            {
                if (_mainConnectionIsCreatedLocal)
                {
                    // Close connection.
                    _mainConnection.Close();
                }
                cmdToExecute.Dispose();
            }
        }


        public override bool Delete(object obj)
        {
            SqlCommand cmdToExecute = new SqlCommand();
            cmdToExecute.CommandText = "dbo.[sp_t_Report_SalesLink_Delete]";
            cmdToExecute.CommandType = CommandType.StoredProcedure;

            // Use base class' connection object
            cmdToExecute.Connection = _mainConnection;

            try
            {
                cmdToExecute.Parameters.Add(new SqlParameter("@guidReport_SalesLink_ID", SqlDbType.UniqueIdentifier, 16, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, SqlGuid.Parse(obj.ToString())));

                if (_mainConnectionIsCreatedLocal)
                {
                    // Open connection.
                    _mainConnection.Open();
                }
                else
                {
                    if (_mainConnectionProvider.IsTransactionPending)
                    {
                        cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
                    }
                }

                // Execute query.
                _rowsAffected = cmdToExecute.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                // some error occured. Bubble it to caller and encapsulate Exception object
                throw new Exception("T_Report_SalesLink::Delete::Error occured.", ex);
            }
            finally
            {
                if (_mainConnectionIsCreatedLocal)
                {
                    // Close connection.
                    _mainConnection.Close();
                }
                cmdToExecute.Dispose();
            }
        }


        public override object SelectOne(object obj)
        {
            SqlCommand cmdToExecute = new SqlCommand();
            cmdToExecute.CommandText = "dbo.[sp_t_Report_SalesLink_SelectOne]";
            cmdToExecute.CommandType = CommandType.StoredProcedure;
            DataTable toReturn = new DataTable("t_Report_SalesLink");
            SqlDataAdapter adapter = new SqlDataAdapter(cmdToExecute);

            // Use base class' connection object
            cmdToExecute.Connection = _mainConnection;
            this._objMessage = new DataEntity.T_Report_SalesLink();
            try
            {
                cmdToExecute.Parameters.Add(new SqlParameter("@guidReport_SalesLink_ID", SqlDbType.UniqueIdentifier, 16, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, SqlGuid.Parse(obj.ToString())));

                if (_mainConnectionIsCreatedLocal)
                {
                    // Open connection.
                    _mainConnection.Open();
                }
                else
                {
                    if (_mainConnectionProvider.IsTransactionPending)
                    {
                        cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
                    }
                }

                // Execute query.
                adapter.Fill(toReturn);
                if (toReturn.Rows.Count > 0)
                {
                    _objMessage.Report_SalesLink_ID = (Guid)toReturn.Rows[0]["Report_SalesLink_ID"];
                    _objMessage.Report_SalesLink_ProjectID = (Guid)toReturn.Rows[0]["Report_SalesLink_ProjectID"];
                    _objMessage.Report_SalesLink_ExchangeTypeID = (Int32)toReturn.Rows[0]["Report_SalesLink_ExchangeTypeID"];
                    _objMessage.Report_SalesLink_PropertyTypeID = (Int32)toReturn.Rows[0]["Report_SalesLink_PropertyTypeID"];
                    _objMessage.Report_SalesLink_ExchangeDate = toReturn.Rows[0]["Report_SalesLink_ExchangeDate"] == System.DBNull.Value ? SqlDateTime.Null : (DateTime)toReturn.Rows[0]["Report_SalesLink_ExchangeDate"];
                    _objMessage.Report_SalesLink_ReportNO = toReturn.Rows[0]["Report_SalesLink_ReportNO"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_ReportNO"];
                    _objMessage.Report_SalesLink_Subscribe = toReturn.Rows[0]["Report_SalesLink_Subscribe"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_Subscribe"];
                    _objMessage.Report_SalesLink_Operator = toReturn.Rows[0]["Report_SalesLink_Operator"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_Operator"];
                    _objMessage.Report_SalesLink_SellUnit = toReturn.Rows[0]["Report_SalesLink_SellUnit"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_SellUnit"];
                    _objMessage.Report_SalesLink_Buyer = toReturn.Rows[0]["Report_SalesLink_Buyer"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_Buyer"];
                    _objMessage.Report_SalesLink_Area = toReturn.Rows[0]["Report_SalesLink_Area"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_Area"];
                    _objMessage.Report_SalesLink_Discount = toReturn.Rows[0]["Report_SalesLink_Discount"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_Discount"];
                    _objMessage.Report_SalesLink_PayType = toReturn.Rows[0]["Report_SalesLink_PayType"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_PayType"];
                    _objMessage.Report_SalesLink_Price = toReturn.Rows[0]["Report_SalesLink_Price"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_Price"];
                    _objMessage.Report_SalesLink_Margins = toReturn.Rows[0]["Report_SalesLink_Margins"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_Margins"];
                    _objMessage.Report_SalesLink_AgencyCost = toReturn.Rows[0]["Report_SalesLink_AgencyCost"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_AgencyCost"];
                    _objMessage.Report_SalesLink_CancelComm = toReturn.Rows[0]["Report_SalesLink_CancelComm"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_CancelComm"];
                    _objMessage.Report_SalesLink_OriginalArea = toReturn.Rows[0]["Report_SalesLink_OriginalArea"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_OriginalArea"];
                    _objMessage.Report_SalesLink_OriginalPrice = toReturn.Rows[0]["Report_SalesLink_OriginalPrice"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_OriginalPrice"];
                    _objMessage.Report_SalesLink_BarchSalse = toReturn.Rows[0]["Report_SalesLink_BarchSalse"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_BarchSalse"];
                    _objMessage.Report_SalesLink_Variations = toReturn.Rows[0]["Report_SalesLink_Variations"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_Variations"];
                    _objMessage.Report_SalesLink_IDNumber = toReturn.Rows[0]["Report_SalesLink_IDNumber"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_IDNumber"];
                    _objMessage.Report_SalesLink_Tel = toReturn.Rows[0]["Report_SalesLink_Tel"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_Tel"];
                    _objMessage.Report_SalesLink_CustomerAddress = toReturn.Rows[0]["Report_SalesLink_CustomerAddress"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_CustomerAddress"];
                    _objMessage.Report_SalesLink_PostCode = toReturn.Rows[0]["Report_SalesLink_PostCode"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_PostCode"];
                    _objMessage.Report_SalesLink_SalesArea = toReturn.Rows[0]["Report_SalesLink_SalesArea"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_SalesArea"];
                    _objMessage.Report_SalesLink_OriginalContractPrice = toReturn.Rows[0]["Report_SalesLink_OriginalContractPrice"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_OriginalContractPrice"];
                    _objMessage.Report_SalesLink_BigDate = toReturn.Rows[0]["Report_SalesLink_BigDate"] == System.DBNull.Value ? SqlDateTime.Null : (DateTime)toReturn.Rows[0]["Report_SalesLink_BigDate"];
                    _objMessage.Report_SalesLink_BigPrice = toReturn.Rows[0]["Report_SalesLink_BigPrice"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_BigPrice"];
                    _objMessage.Report_SalesLink_BigSumPrice = toReturn.Rows[0]["Report_SalesLink_BigSumPrice"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_BigSumPrice"];
                    _objMessage.Report_SalesLink_ContractDate = toReturn.Rows[0]["Report_SalesLink_ContractDate"] == System.DBNull.Value ? SqlDateTime.Null : (DateTime)toReturn.Rows[0]["Report_SalesLink_ContractDate"];
                    _objMessage.Report_SalesLink_ContractArea = toReturn.Rows[0]["Report_SalesLink_ContractArea"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_ContractArea"];
                    _objMessage.Report_SalesLink_ContractPrice = toReturn.Rows[0]["Report_SalesLink_ContractPrice"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_ContractPrice"];
                    _objMessage.Report_SalesLink_ContractSumPrice = toReturn.Rows[0]["Report_SalesLink_ContractSumPrice"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_ContractSumPrice"];
                    _objMessage.Report_SalesLink_LoanAmount = toReturn.Rows[0]["Report_SalesLink_LoanAmount"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_LoanAmount"];
                    _objMessage.Report_SalesLink_ContractLoansDate = toReturn.Rows[0]["Report_SalesLink_ContractLoansDate"] == System.DBNull.Value ? SqlDateTime.Null : (DateTime)toReturn.Rows[0]["Report_SalesLink_ContractLoansDate"];
                    _objMessage.Report_SalesLink_LentDate = toReturn.Rows[0]["Report_SalesLink_LentDate"] == System.DBNull.Value ? SqlDateTime.Null : (DateTime)toReturn.Rows[0]["Report_SalesLink_LentDate"];
                    _objMessage.Report_SSalesLink_LentAmount = toReturn.Rows[0]["Report_SSalesLink_LentAmount"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SSalesLink_LentAmount"];
                    _objMessage.Report_SalesLink_TotalReceipt = toReturn.Rows[0]["Report_SalesLink_TotalReceipt"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_TotalReceipt"];
                    _objMessage.Report_SalesLink_RestHouse = toReturn.Rows[0]["Report_SalesLink_RestHouse"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)toReturn.Rows[0]["Report_SalesLink_RestHouse"];
                    _objMessage.Report_SalesLink_GiveHouseDate = toReturn.Rows[0]["Report_SalesLink_GiveHouseDate"] == System.DBNull.Value ? SqlDateTime.Null : (DateTime)toReturn.Rows[0]["Report_SalesLink_GiveHouseDate"];
                    _objMessage.Report_SalesLink_Departments = toReturn.Rows[0]["Report_SalesLink_Departments"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_Departments"];
                    _objMessage.Report_SalesLink_Branches = toReturn.Rows[0]["Report_SalesLink_Branches"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_Branches"];
                    _objMessage.Report_SalesLink_SalesNames = toReturn.Rows[0]["Report_SalesLink_SalesNames"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_SalesNames"];
                    _objMessage.Report_SalesLink_SalesNumber = toReturn.Rows[0]["Report_SalesLink_SalesNumber"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["Report_SalesLink_SalesNumber"];
                    _objMessage.Report_Plan_Audit = toReturn.Rows[0]["Report_Plan_Audit"] == System.DBNull.Value ? SqlInt32.Null : (Int32)toReturn.Rows[0]["Report_Plan_Audit"];
                }
                return this._objMessage;
            }
            catch (Exception ex)
            {
                // some error occured. Bubble it to caller and encapsulate Exception object
                throw new Exception("T_Report_SalesLink::SelectOne::Error occured.", ex);
            }
            finally
            {
                if (_mainConnectionIsCreatedLocal)
                {
                    // Close connection.
                    _mainConnection.Close();
                }
                cmdToExecute.Dispose();
                adapter.Dispose();
            }
        }
    }
}
